<template>
    <div class="top-box">
        <el-dropdown split-button type="primary">
            欢迎：{{ loginName }}
            <template #dropdown>
                <el-dropdown-menu>
                    <el-dropdown-item @click="loginOut">退出登录</el-dropdown-item>
                </el-dropdown-menu>
            </template>
        </el-dropdown>
    </div>
</template>
  
<script setup lang="ts">
import { useRouter } from "vue-router";
let router = useRouter();
// 获取登录的用户名
let loginName = localStorage.getItem("adminname");
// 点击退出
const loginOut = () => {
    // localStorage.removeItem('admin-token');
    // localStorage.removeItem('adminname');
    // localStorage.removeItem('role');
    // 跳转到登录
    router.push("/login");
}
</script>
  
<style lang="less" scoped>
.top-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;

    .iconfont {
        color: #fff;
        font-size: 26px;
        cursor: pointer;
    }
}
</style>
  